// 题目链接：https://www.luogu.com.cn/problem/P1332

#include <iostream>
#include <cstring>
#include <queue>

using namespace std;

#define x first
#define y second

typedef pair<int, int> PII;

const int N = 505;
const int M = 505;

int n, m, a, b;
int times[N][M];
queue<PII> q;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

void BFS()
{
    while (!q.empty())
    {
        auto t = q.front();
        q.pop();

        for (int i = 0; i < 4; ++i)
        {
            int next_x = t.x + dx[i];
            int next_y = t.y + dy[i];

            if (next_x < 1 || next_x > n || next_y < 1 || next_y > m)
                continue;
            if (times[next_x][next_y] >= 0)
                continue;

            q.push({next_x, next_y});
            times[next_x][next_y] = times[t.x][t.y] + 1;
        }
    }
}

int main()
{
    int x, y;
    memset(times, -1, sizeof times);
    scanf("%d %d %d %d", &n, &m, &a, &b);
    while (a--)
    {
        scanf("%d %d", &x, &y);
        q.push({x, y});
        times[x][y] = 0;
    }

    BFS();

    while (b--)
    {
        scanf("%d %d", &x, &y);
        printf("%d\n", times[x][y]);
    }

    return 0;
}